package logic

import (
	"context"
	"goodsrpc/mysql"

	"goodsrpc/goods"
	"goodsrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseDetailsLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHouseDetailsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseDetailsLogic {
	return &HouseDetailsLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *HouseDetailsLogic) HouseDetails(in *goods.HouseDetailsRequest) (*goods.HouseDetailsResponse, error) {
	// todo: add your logic here and delete this line
	var h mysql.House
	mysql.DB.Debug().Where("id = ?", in.Id).Find(&h)

	return &goods.HouseDetailsResponse{
		Name:        h.Name,
		Price:       uint64(h.Price),
		FacePrice:   uint64(h.FacePrice),
		HouseNumber: h.HouseNumber,
		ListingTime: h.ListingTime,
		State:       h.State,
		UserId:      h.UserId,
	}, nil
}
